<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>Luat DTU 配置工具 v1.1</title>
    <link rel="stylesheet" href="node_modules/element-ui/lib/theme-chalk/index.css">
    <style>
        .el-header,
        .el-footer {
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
        }

        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
            line-height: 200px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
            line-height: 20px;
        }

        body>.el-container {
            margin-bottom: 20px;
        }

        .el-form-item {
            line-height: 16px;
            margin-bottom: 2px;
        }

        .el-form-item__label {
            text-align: left;
        }

        .el-radio-group {
            margin-top: 16px;
        }
    </style>
</head>

<body>
    <div id="app">
        <el-container style="height: 100%;">
            <el-aside>
                <el-main>
                    <div v-if="has_chrome_serial">
                        <el-input v-model="devinfo.imei"><template slot="prepend">IMEI</template></el-input>
                        <el-input v-model="devinfo.iccid"><template slot="prepend">ICCID</template></el-input>
                        <el-input v-model="devinfo.csq"><template slot="prepend">GSM信号强度</template></el-input>
                        <el-input v-model="devinfo.ver"><template slot="prepend">版本号</template></el-input>
                        <el-input v-model="devinfo.project"><template slot="prepend">项目名称</template></el-input>
                        <el-input v-model="devinfo.location" v-if="false"><template slot="prepend">设备坐标</template>
                        </el-input>
                        <el-input v-model="devinfo.vbatt"><template slot="prepend">VBAT电压</template></el-input>
                    </div>
                    <div>
                        <p>DTU固件由稀饭放姜(张涛)提供技术支持,有任何疑问,请加入QQ群952343033咨询</p>
                        <p>DTU固件下载</p>
                        <p>QQ群文件: 952343033</p>
                        <p>2G: <a
                                href="https://github.com/hotdll/irtu-rda8955/releases" target="_blank">https://github.com/hotdll/irtu-rda8955/releases</a>
                        </p>
                        <p>4G: <a
                                href="https://github.com/hotdll/irtu-asr1802/releases" target="_blank">https://github.com/hotdll/irtu-asr1802/releases</a>
                        </p>
                    </div>
                </el-main>
            </el-aside>
            <el-container>
                <el-header>
                    <el-select v-model="cur_serial" placeholder="请选择串口" v-if="has_chrome_serial">
                        <el-option v-for="item in serials" :key="item.path" :label="item.nickName" :value="item.path">
                        </el-option>
                    </el-select>
                    <el-button @click="reload_serial_list()" v-if="has_chrome_serial">刷新</el-button>
                    <el-button @click="read_devinfo()" v-if="has_chrome_serial">读设备信息</el-button>
                    <el-button @click="read_dtu_config()" v-if="has_chrome_serial">读配置</el-button>
                    <el-button @click="write_dtu_config()" v-if="has_chrome_serial">写配置</el-button>
                    <el-button @click="copy_dtu_config_to_clipboard()">复制到剪贴板</el-button>
                    <el-button @click="import_dtu_config()" v-if="has_chrome_serial">导入配置</el-button>
                </el-header>
                <el-main>
                    <el-tabs v-model="cur_menu_tab" type="border-card">
                        <el-tab-pane label="基本参数" name="basic">
                            <el-form label-width="200px">
                                <el-form-item label="模式">
                                    <el-radio-group v-model.number="dtu_config.passon">
                                        <el-radio :label="0">透传</el-radio>
                                        <el-radio :label="1">单片机控制</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="是否加设备识别码IMEI">
                                    <el-radio-group v-model.number="dtu_config.plate">
                                        <el-radio :label="0">不加</el-radio>
                                        <el-radio :label="1">添加</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="报文转换(bin/hex)">
                                    <el-radio-group v-model.number="dtu_config.convert">
                                        <el-radio :label="0">不转</el-radio>
                                        <el-radio :label="1">要转</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="首次登陆服务器发送注册信息">
                                    <el-radio-group v-model.number="dtu_config.reg">
                                        <el-radio :label="0">不发</el-radio>
                                        <el-radio :label="1">要转</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="参数版本号">
                                    <el-input v-model.number="dtu_config.param_ver" type="number"></el-input>
                                </el-form-item>
                                <el-form-item label="每分钟最大串口流量(Byte)">
                                    <el-input v-model.number="dtu_config.flow" type="number"></el-input>
                                </el-form-item>
                                <el-form-item label="是否自动更新">
                                    <el-radio-group v-model.number="dtu_config.fota">
                                        <el-radio :label="1">开启</el-radio>
                                        <el-radio :label="0">关闭</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="电源模式">
                                    <el-radio-group v-model="dtu_config.pwrmod">
                                        <el-radio label="normal">正常</el-radio>
                                        <el-radio label="energy">节能</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="配置密码">
                                    <el-input v-model="dtu_config.password"></el-input>
                                </el-form-item>
                                <el-form-item label="串口分帧超时">
                                    <el-input v-model.number="dtu_config.uartReadTime" type="number"></el-input>
                                </el-form-item>
                                <el-form-item label="网络分帧超时">
                                    <el-input v-model.number="dtu_config.netReadTime" type="number"></el-input>
                                </el-form-item>
                                <el-form-item label="日志输出">
                                    <el-radio-group v-model="dtu_config.nolog">
                                        <el-radio label="1">开启</el-radio>
                                        <el-radio label="0">关闭</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="串口配置" name="uart">
                            <el-tabs v-model="cur_uart_tab" type="border-card">
                                <el-tab-pane :label="'串口'+uart[0]" :name="'uart' + uart[0]"
                                    v-for="uart in dtu_config.uconf" v-bind:key="uart[0]">
                                    <el-form label-width="200px">
                                        <el-form-item :label="'串口'+uart[0]+'波特率'">
                                            <el-select v-model="uart[1]">
                                                <el-option label="2400" value="2400"></el-option>
                                                <el-option label="4800" value="4800"></el-option>
                                                <el-option label="9600" value="9600"></el-option>
                                                <el-option label="14400" value="14400"></el-option>
                                                <el-option label="19200" value="19200"></el-option>
                                                <el-option label="38400" value="38400"></el-option>
                                                <el-option label="56000" value="56000"></el-option>
                                                <el-option label="57600" value="57600"></el-option>
                                                <el-option label="115200" value="115200"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item label="数据位">
                                            <el-radio-group v-model.number="uart[2]">
                                                <el-radio :label="8">8</el-radio>
                                                <el-radio :label="7">7</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="校验位">
                                            <el-radio-group v-model.number="uart[3]">
                                                <el-radio :label="0">EVEN</el-radio>
                                                <el-radio :label="1">ODD</el-radio>
                                                <el-radio :label="2">NONE</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="停止位">
                                            <el-radio-group v-model.number="uart[4]">
                                                <el-radio :label="0">1</el-radio>
                                                <el-radio :label="1">2</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="485方向控制GPIO">
                                            <el-select v-model="uart[5]">
                                                <el-option label="" value="">禁用</el-option>
                                                <el-option :label="'pin'+n" :value="'pin'+n" v-for="n in 128"
                                                    v-bind:key="n">pin{{n}}</el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-form>
                                </el-tab-pane>
                            </el-tabs>
                        </el-tab-pane>
                        <el-tab-pane label="网络通道参数" name="net">
                            <el-tabs v-model="cur_net_tab" type="border-card">
                                <el-tab-pane :label="'通道'+n" :name="'net' + n" v-for="n in 7" v-bind:key="n">
                                    <el-form label-width="200px">
                                        <el-form-item label="通道类型">
                                            <el-select v-model="dtu_config.conf[n-1][0]">
                                                <el-option label="停用" value=""></el-option>
                                                <el-option label="TCP" value="tcp"></el-option>
                                                <el-option label="UDP" value="udp"></el-option>
                                                <el-option label="MQTT" value="mqtt"></el-option>
                                                <el-option label="HTTP" value="http"></el-option>
                                                <el-option label="中移动onenet" value="onenet"></el-option>
                                                <el-option label="百度天工" value="bdiot"></el-option>
                                                <el-option label="阿里云IOT" value="aliyun"></el-option>
                                                <el-option label="腾讯云IOT" value="txiot"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <!-- TCP/UDP 的配置项 -->
                                        <div
                                            v-if="dtu_config.conf[n-1][0] == 'tcp' || dtu_config.conf[n-1][0] == 'udp'">
                                            <el-form-item label="心跳包">

                                            </el-form-item>
                                            <el-form-item label="心跳间隔">
                                                <el-input v-model.number="dtu_config.conf[n-1][2]" type="number">
                                                </el-input>
                                            </el-form-item>
                                            <el-form-item label="服务器域名或ip">
                                                <el-input v-model="dtu_config.conf[n-1][3]"></el-input>
                                            </el-form-item>
                                            <el-form-item label="服务器端口号">
                                                <el-input v-model.number="dtu_config.conf[n-1][4]" type="number">
                                                </el-input>
                                            </el-form-item>
                                            <el-form-item label="通道捆绑的串口ID">
                                                <el-select v-model="dtu_config.conf[n-1][5]">
                                                    <el-option label="1" value="1"></el-option>
                                                    <el-option label="2" value="2"></el-option>
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="被动上报间隔">
                                                <el-input v-model="dtu_config.conf[n-1][6]"></el-input>
                                            </el-form-item>
                                            <el-form-item label="被动采集间隔">
                                                <el-input v-model="dtu_config.conf[n-1][7]"></el-input>
                                            </el-form-item>
                                            <el-form-item label="自动任务间隔时间">
                                                <el-input v-model="dtu_config.conf[n-1][8]"></el-input>
                                            </el-form-item>
                                            <!-- SSL -->
                                        </div>
                                        <!-- HTTP -->
                                        <!-- ["http", "1", "post", "nutz.cn/post", 30, "1", "1", "", "", 1, 1, 0] -->
                                        <div v-if="dtu_config.conf[n-1][0] == 'http'">
                                            <el-form-item label="通道捆绑的串口ID">
                                                <el-select v-model="dtu_config.conf[n-1][1]">
                                                    <el-option label="1" value="1"></el-option>
                                                    <el-option label="2" value="2"></el-option>
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="Http方法">
                                                <el-select v-model="dtu_config.conf[n-1][2]">
                                                    <el-option label="get" value="get"></el-option>
                                                    <el-option label="post" value="post"></el-option>
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="URL">
                                                <el-input v-model="dtu_config.conf[n-1][3]"></el-input>
                                            </el-form-item>
                                            <el-form-item label="timeout">
                                                <el-input v-model.number="dtu_config.conf[n-1][4]" type="number">
                                                </el-input>
                                            </el-form-item>
                                            <el-form-item label="请求类型">
                                                <el-radio-group v-model="dtu_config.conf[n-1][5]">
                                                    <el-radio label="1">body</el-radio>
                                                    <el-radio label="2">param</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="type">
                                                <el-radio-group v-model="dtu_config.conf[n-1][6]">
                                                    <el-radio label="1">urlencode</el-radio>
                                                    <el-radio label="2">json</el-radio>
                                                    <el-radio label="3">stream</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="Baisc鉴权">
                                                <el-input v-model="dtu_config.conf[n-1][7]"></el-input>
                                            </el-form-item>
                                            <el-form-item label="Head">
                                                <el-input v-model="dtu_config.conf[n-1][8]"></el-input>
                                            </el-form-item>
                                            <!-- 过滤 -->
                                        </div>
                                        <!-- MQTT -->
                                        <!-- ["mqtt", 300, 1800, "180.97.80.55", "1883", "", "", 1, "/server", "/device", 0, 0, 1, "", "1"] -->
                                        <div v-if="dtu_config.conf[n-1][0] == 'mqtt'">

                                        </div>
                                        <!-- 中移动 -->
                                        <div v-if="dtu_config.conf[n-1][0] == 'onenet'">

                                        </div>
                                        <!-- 百度天工 -->
                                        <div v-if="dtu_config.conf[n-1][0] == 'bdiot'">

                                        </div>
                                        <!-- 阿里云iot -->
                                        <div v-if="dtu_config.conf[n-1][0] == 'aliyun'">

                                        </div>
                                        <!-- 腾讯云iot -->
                                        <div v-if="dtu_config.conf[n-1][0] == 'txiot'">

                                        </div>
                                    </el-form>
                            </el-tabs>
                        </el-tab-pane>
                        <el-tab-pane label="预置信息" name="preset">预置信息</el-tab-pane>
                        <el-tab-pane label="GPIO" name="gpio">
                            <el-form label-width="200px">
                                <el-form-item label="NetLED">
                                    <el-select v-model="dtu_config.pins[0]">
                                        <el-option label="" value="">禁用</el-option>
                                        <el-option :label="'pin'+n" :value="'pin'+n" v-for="n in 128" v-bind:key="n">
                                            pin{{n}}</el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="NetRDY">
                                    <el-select v-model="dtu_config.pins[1]">
                                        <el-option label="" value="">禁用</el-option>
                                        <el-option :label="'pin'+n" :value="'pin'+n" v-for="n in 128" v-bind:key="n">
                                            pin{{n}}</el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="RSTCNF">
                                    <el-select v-model="dtu_config.pins[2]">
                                        <el-option label="" value="">禁用</el-option>
                                        <el-option :label="'pin'+n" :value="'pin'+n" v-for="n in 128" v-bind:key="n">
                                            pin{{n}}</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="GPS" name="gps">GPS</el-tab-pane>
                        <el-tab-pane label="数据流" name="dataflow">数据流</el-tab-pane>
                        <el-tab-pane label="预警" name="warn">预警</el-tab-pane>
                        <el-tab-pane label="任务" name="task">任务</el-tab-pane>
                    </el-tabs>
                </el-main>
                <el-footer rows="40" v-if="sys_log.visible">
                    <el-input type="textarea" v-model="sys_log.data">
                        <template slot="prepend">日志</template>
                    </el-input>
                </el-footer>
            </el-container>
        </el-container>
    </div>
</body>
<script src="node_modules/vue/dist/vue.js"></script>
<script src="node_modules/element-ui/lib/index.js"></script>
<script src="dtu/default.js"></script>
<script src="dtu/dtu.js"></script>

</html>